<template>
	<view class="taber flex  align-center justify-around benben-flex-layout">
		<view class="taber_0 flex flex-direction align-center"  @tap.stop="goTabBer(1)">
			<image class='taber_1' mode="aspectFit" :src='typeOr == 1 ? "/static/tab/1.png" : "/static/tab/1_1.png"'></image>
			<view :class="typeOr == 1 ? 'taber_2' : 'taber_3'">抢单大厅</view>
		</view>
		<view class="taber_0 flex flex-direction align-center" @tap.stop="goTabBer(4)">
			<image class='taber_1' mode="aspectFit" :src=' "/static/tab/4.png"'></image>
			<view :class="typeOr == 4 ? 'taber_2' : 'taber_3'">扫码</view>
		</view>
		<view class="taber_0 flex flex-direction align-center"  @tap.stop="goTabBer(2)">
			<image class='taber_1' mode="aspectFit" :src='typeOr == 2 ? "/static/tab/2.png" : "/static/tab/2_1.png"'></image>
			<view :class="typeOr == 2 ? 'taber_2' : 'taber_3'">订单</view>
		</view>
		<view class="taber_0 flex flex-direction align-center"  @tap.stop="goTabBer(3)">
			<image class='taber_1' mode="aspectFit" :src='typeOr == 3 ? "/static/tab/3.png" : "/static/tab/3_1.png"'></image>
			<view :class="typeOr == 3 ? 'taber_2' : 'taber_3'">我的</view>
		</view>
		
		
	</view>
</template>

<script>
	export default {
		props: {
		
			typeOr:{
				type: String,
				default: '1',
			}
		},
		data() {
			return {
				
			}
		},
		methods: {
			goTabBer(type) {
				let url = ''
				let _this = this
				if(type == 1){
					url = '/pages/tabBar/index/index'
				}else if(type == 2){
					url = '/pages/tabBar/order/order'
				}else if(type == 3){
					url = '/pages/tabBar/my/my'
				}else if(type == 4){
					// url = '/pages/tabBar/my/my'
					uni.scanCode({
						onlyFromCamera: true,
						success: function (res) {
							console.log('条码类型：' + res.scanType);
							console.log('条码内容：' + res.result);
							if(res.result){
								_this.jiedan(res.result)
							// 	let page = res.result.split('?')
							// 	console.log(page,'接受参数')
							// 	uni.navigateTo({
							// 		url:`/pages/tabBar/xuanzecanpin/xuanzecanpin?${page[1]}`
							// 	})
							}
							
							// 
						}
					});
					return
				}
				uni.switchTab({
					url: url
				})
			},
			async jiedan(result){
				
				let res = await this.$api.post(global.apiUrls.post646d678dd2afe, {
					order_sn: result
				});
				if (res.data.code != 1) {
					this.$message.info(res.data.msg);
					return
				}
				uni.switchTab({
					url: '/pages/tabBar/order/order'
				})
			},
		},
	}
</script>

<style lang="scss" scoped>
	.taber {
		position: fixed;
		bottom: 0;
		left: 0;
		width: 100%;
		display: flex;
		padding-top: 8rpx;
		// height: 98rpx;
		// box-shadow: 0px -1px 6px 1px rgba(0,0,0,0.08);
		background: #FFFFFF;
		padding-bottom:calc(8rpx + constant(safe-area-inset-bottom)) !important;
		padding-bottom:calc(8rpx + env(safe-area-inset-bottom)) !important;
		box-sizing: border-box;
		z-index: 10000;
	}
	.taber_1{
		width: 48rpx;
		height: 48rpx;
	}
	.taber_2{
		font-weight: bold;
		font-size: 20rpx;
		color: #F7A352;
	}
	.taber_3{
		font-weight: 400;
		font-size: 20rpx;
		color: #999999;
	}
</style>
